<script>
	highlight_subnav('orderdetailed');

</script>
<style>
	th{
		white-space: nowrap;
	}
	td{
		word-wrap:break-word; 
		word-break:break-all; 
	}
</style>

<div class="tpl-content-wrapper">
	<div class="row-content am-cf">
		<div class="row">
			<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
				<div class="widget am-cf">
					<div class="widget-head am-cf">
						<div class="widget-title  am-cf">订单管理</div>
					</div>
					<div class="row">
						<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
							<form action="" method="get" id="form1" class="am-form tpl-form-border-form">
								<div class=" am-u-sm-12 am-u-md-12 am-u-lg-12" >
									<div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
										<div class="am-form-group">
											<label for="user-weibo" class="am-u-sm-5 am-form-label">开始时间</label>
											<div class="am-u-sm-7">
												<input type="text" id='start_time' name='start_time'  value="<?php echo isset($_GET['start_time']) ? $_GET['start_time']: ''?>" placeholder="点击选择时间">							
											
											</div>
										</div>
									</div>
									<div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
										<div class="am-form-group">
											<label for="user-weibo" class="am-u-sm-5 am-form-label">结束时间 </label>
											<div class="am-u-sm-7">
												<input type="text" id='end_time' name='end_time' value="<?php echo isset($_GET['end_time']) ? $_GET['end_time']:''?>" placeholder="点击选择时间">
											
											</div>
										</div>
									</div>	
									
									<div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
										<div class="am-form-group">
											<label  class="am-u-sm-5 am-form-label">状态 </label>
											<div class="am-u-sm-7">
												<select name='status' data-am-selected="{btnSize: 'sm'}" id="status">
													<option value=""></option>
													<?php $status_arr=array('全部','支付成功(待发货)','已发货','未支付','超时','已退押金');
													foreach ($status_arr as $key => $value) {?>
														<option value="<?php echo $key?>" <?php if(isset($_GET['status'])){if($_GET['status'] == $key){echo "selected";}}?>><?php echo $value;?></option>
													<?php }?>
												</select>
											</div>
										</div>
									</div>	
									</form>				
									<div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
										<a class="am-btn am-btn-default am-btn-success" href="#123" onclick='submitform()' value="提交">提交</a> &nbsp;
										<a class="am-btn am-btn-default am-btn-success" href="/admin/order/orderlist">清除所有选择</a> &nbsp;
										<a href="/admin/order/orderlist?export=1<?php if(isset($_GET['status'])) echo '&status='.$_GET['status']?><?php if(isset($_GET['start_time'])) echo '&start_time='.$_GET['start_time']?><?php if(isset($_GET['end_time'])) echo '&end_time='.$_GET['end_time']?>"
													class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 导出</a>
									</div>			
									<!--开始时间 
									<input type="text" id='start_time' name='start_time' value="<?php echo isset($_GET['start_time']) ? $_GET['start_time']: date('Y-m-d')?>">							
									结束时间 
									<input type="text" id='end_time' name='end_time' value="<?php echo isset($_GET['end_time']) ? $_GET['end_time']:date('Y-m-d')?>">-->
								</div>
							
						</div>
					</div>
					<form action="" method="get" id='from2'>
						<div class="am-u-sm-12 am-u-md-12 am-u-lg-4 am-u-lg-offset-8" style="margin-top:20px;margin-bottom:20px;">
							<div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
								<input type="text" class="am-form-field" name='name' placeholder="输入订单号或者手机号进行搜索" value="<?php echo isset($_GET['name'])?$_GET['name']:'' ?>">
								<span class="am-input-group-btn">
									<button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="submit"></button>
								</span>
							</div>
						</div>
					</form>



					
					<div class="am-u-sm-12">
						<table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
							<thead>
								<tr>
									<th>序号</th>
									<th>订单id</th>
									<th>总价格</th>
									<th>状态</th>
									<th>支付方式</th>
									<th>商品数量</th>
									<th>创建时间</th>
									<th>买家姓名</th>
									<th>详细地址</th>
									<th>手机号码</th>
									<th>买家备注</th>
									<th>快递公司名</th>
									<th>快递单号</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach ($data as $key => $value) : ?>
								<tr class="gradeX">
									<td style="width:1%;" class="am-text-middle">
										<?php echo $key+1;?>
									</td>
									<td style="width: 2%;" class="am-text-middle">
										<?php echo $value['order_id'];?>
									</td>
									<td style="width: 2%;" class="am-text-middle">
										<?php echo $value['price'];?>
									</td>
									<td style="width: 5%;" class="am-text-middle">
										<?php echo $value['status'];?>
									</td>
									<td style="width: 2%;" class="am-text-middle">
										<?php echo $value['paytype']==1 || $value['paytype']==2 ? '微信':'支付宝';?>
									</td>
									<td style="width: 1%;" class="am-text-middle">
										<?php echo $value['amount'];?>
									</td>
									<td style="width: 10%;" class="am-text-middle">
										<?php echo date('Y-m-d H:i:s',$value['create_time']);?>
									</td>
									<td style="width: 1%;" class="am-text-middle">
										<?php echo $value['consignee'];?>
									</td>
									<td style="width: 15%;" class="am-text-middle">
										<?php echo $value['address'];?>
									</td>
									<td style="width: 8%;" class="am-text-middle">
										<?php echo $value['mobile'];?>
									</td>
									<td style="width: 5%;" class="am-text-middle">
										<?php echo mb_substr($value['leave'],0,4,'utf-8');if(mb_strlen($value['leave'])>5){echo '....';}?>
									</td>
									<td style="width: 6%;" class="am-text-middle"><?php echo $value['express'];?></td>
									<td style="width: 10%;" class="am-text-middle"><?php echo $value['logistics'];?></td>
									<td style="width: 5%; " class="am-text-middle">
										<div class="tpl-table-black-operation">
											<a href="/admin/order/orderdetail?order_id=<?php echo $value['order_id']?>">
                                                            <i class="am-icon-pencl"></i>订单详情
                                                        </a>
										</div>
									</td>
								</tr>
								<?php endforeach;?>
								<!-- more data -->
							</tbody>
						</table>
					</div>
					<div class="am-u-lg-12 am-cf">

						<div class="am-fr">
							<ul class="am-pagination tpl-pagination">
								<?php echo $page;?>
								<!-- <li class=1"am-disabled"><a href="#">«</a></li>
                                            <li class="am-active"><a href="#">1</a></li>
                                            <li><a href="#">2</a></li>
                                            <li><a href="#">3</a></li>
                                            <li><a href="#">4</a></li>
                                            <li><a href="#">5</a></li>
                                            <li><a href="#">»</a></li> -->
							</ul>
						</div>
					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</div>
<script type="text/javascript" src="/static/laydate/laydate.js"></script>
<script type="text/javascript">
	$(function () {
		$("#status").change(function () {
			var start_time = $('#start_time').val();
			var end_time = $('#end_time').val();
			if (start_time > end_time) {
				alert('开始时间不能大于结束时间');
				return;
			}
			$("#form1").submit();
		});

		laydate({
			elem: '#start_time'
		});
		laydate({
			elem: '#end_time'
		});


	});
	function submitform() {
		//提交表单
		var start_time = $('#start_time').val();
		var end_time = $('#end_time').val();
		if (start_time > end_time) {
			alert('开始时间不能大于结束时间');
			return;
		}

		$("#form1").submit();
	}

</script>
